package com.cskaoyan.mall.product.controller;

import com.cskaoyan.mall.common.result.Result;
import com.cskaoyan.mall.product.dto.PlatformAttributeInfoDTO;
import com.cskaoyan.mall.product.dto.PlatformAttributeValueDTO;
import com.cskaoyan.mall.product.query.PlatformAttributeParam;
import com.cskaoyan.mall.product.service.PlatformAttributeService;
import com.cskaoyan.mall.product.service.impl.PlatformAttributeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping
public class AdminProductAttrInfoController {

    @Autowired
    private PlatformAttributeServiceImpl platformAttributeService;

    @GetMapping("/admin/product/attrInfoList/{firstLevelCategoryId}/{secondLevelCategoryId}/{thirdLevelCategoryId}")
    public Result getAttrInfoList(@PathVariable Long firstLevelCategoryId, @PathVariable Long secondLevelCategoryId, @PathVariable Long thirdLevelCategoryId){
        List<PlatformAttributeInfoDTO> platformAttributeInfoDTOList=platformAttributeService.getPlatformAttrInfoList(firstLevelCategoryId,secondLevelCategoryId,thirdLevelCategoryId);
        return Result.ok(platformAttributeInfoDTOList);
    }
    @GetMapping("/admin/product/getAttrValueList/{attrId}")
    public Result<List<PlatformAttributeValueDTO>> getAttrInfoDTO(@PathVariable Long attrId) {
        List<PlatformAttributeValueDTO> platformAttributeValueDTOSList=platformAttributeService.getPlatformAttrInfo(attrId);
        return Result.ok(platformAttributeValueDTOSList);
    }
    @PostMapping("/admin/product/saveAttrInfo")
    public Result saveAttrInfo(@RequestBody PlatformAttributeParam platformAttributeParam) {
        platformAttributeService.savePlatformAttrInfo(platformAttributeParam);
        return Result.ok();
    }

}
